//
// Created by 16933 on 2024/1/13.
//

#ifndef BALANCE_BIKE_MESSAGE_H
#define BALANCE_BIKE_MESSAGE_H

typedef enum {
    READY = 0,
    MPU_INIT_ERROR = 1

}Message_State;

extern Message_State message_state;

#include "stdint.h"
#define FIFO_BUFER_LENGTH 2048
#define UART_DMA_RX_BUFFER_LENGTH 50
typedef struct
{
    uint8_t BEGIN;            /*! 数据帧起始字节，固定值为 0xA5 */
    float forward;            /*! 前 */
    float backward;           /*! 后 */
    float turn;               /*! 正右负左 */
    uint8_t END;            /*! 数据帧起始字节，固定值为 0x5A */
}__attribute__((__packed__)) Message;



typedef enum {
    START = 1,
    DATA_INFO_TYPE = 2,
    DATA_INFO_2 = 3,
    DATA_CONTROL = 4,
    END_INFO = 5,
    END_CONTROL = 6
} BluetoothParseStep;
void BluetoothParse();

void int_to_str(int num, char str[], int* index);
void frac_to_str(double frac, char str[], int precision, int* index);
void dtoa_manual(double num, char str[], int precision);
#endif //BALANCE_BIKE_MESSAGE_H
